package com.demo.reentrantLock;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

public class Condition {
    static ReentrantLock lock = new ReentrantLock();

    public static void main(String[] args) throws InterruptedException {
        //创建一个新的条件变量（休息式）
        java.util.concurrent.locks.Condition condition1 = lock.newCondition();
        java.util.concurrent.locks.Condition condition2 = lock.newCondition();
        lock.lock();
        //进入休息室等待
        condition1.await();
        condition1.awaitUninterruptibly();//不打断的等待
        condition1.await(2, TimeUnit.SECONDS);//超时等待
        condition1.signal();//唤醒休息室中一个等待线程
        condition1.signalAll();//唤醒全部等待线程

    }
}
